package org.hepeng.fabric.gateway.pool;


/**
 * @author he peng
 * @date 2022/3/24
 */
public class FabricGatewayKeyHolder {

    private static final InheritableThreadLocal<GatewayKey> FABRIC_GATEWAY_KEY_THREAD_LOCAL = new InheritableThreadLocal<>();

    public static void set(GatewayKey key) {
        FABRIC_GATEWAY_KEY_THREAD_LOCAL.set(key);
    }

    public static GatewayKey current() {
        return FABRIC_GATEWAY_KEY_THREAD_LOCAL.get();
    }

    public static GatewayKey remove() {

        GatewayKey current = current();
        FABRIC_GATEWAY_KEY_THREAD_LOCAL.remove();
        return current;
    }
}
